package com.xiaomage.ViewDraw14

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.view.View

/**
 * Created by Administrator on 2018/1/14.
 */
class MatrixSaveFlagView2(context:Context):View(context) {
    private var paint=getPaint()
    init {
        setLayerType(LAYER_TYPE_SOFTWARE,null)
    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)

        canvas.save(Canvas.MATRIX_SAVE_FLAG);
        canvas.clipRect(100,0,200,100);
        canvas.drawColor(Color.GREEN);
        canvas.restore();

        canvas.drawColor(Color.YELLOW);





    }


    private fun getPaint():Paint{
        val paint=Paint()
        paint.isAntiAlias=true
        paint.strokeWidth=5f
        paint.color= Color.GREEN
        paint.style= Paint.Style.FILL_AND_STROKE
        return paint
    }
}